refactored draw code into module