reworked for outside input