optimised condition and changed parameter allocation