beginning reverse engineer algorithm