extracted some functions to module Logic.hs