A judge told him he was wasting 'the best years of his life' in prison