Code refactoring of _AT() function in order to add queryDB and strip old unused code.