implemented from() and improved some code