added arrays to simplify the code