Added constrain function for maximising density