added conditions to values, some small check and fixes