Added safteys for bad input