Re-implementation of lemon