cleaning up monadic code a bit)