adding function and coditionals