better error handling, better code organization