finished implementing alexey's suggestions