Refactoring; smarter sig decode function