moved magic number to config file plus basic error handling