redesigned to be more flexible