Simplyfied the code