add condition checking
cover with tests