max val function added
Fixed conflicts