better implementation, still shitty