works for given input