remove some cruft and simplify right() function