added a bit of logic to prevent 500 server error on None objects with len() method