Working but needs refactor