#14: implementing error check