added command handeling and timeout code