added comments and some cleaner control flow in sockRecv