Cleaned up code and refactored timeout

Just cleaned up the code a little. Also shortened the line that creates random characters by using a combination of ranges, to_a and join.