this code is hard to read :|