Replace magic number and add a else if