Fixed hasElements by getting rid of unnecessary code