modified to work on different input