moved buyitem function